import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'context_header.dart';

class SplashPage extends StatefulWidget {
  @override
  _IndexPageState createState() => _IndexPageState();
}

class _IndexPageState extends State<SplashPage>
    with SingleTickerProviderStateMixin {
  AnimationController _animationController;
  Animation _animation;
  @override
  void initState() {

    DeviceUtils.setBarVisible(false);
    //动画控制器
    _animationController = AnimationController(
        vsync: this, duration: Duration(milliseconds: 3000));
    //动画
    _animation = Tween(begin: 0.0, end: 1.0).animate(_animationController);
    //添加状态监听
    _animation.addStatusListener((status) {
      if (AnimationStatus.completed == status) {
        DeviceUtils.setBarVisible(true);
        DeviceUtils.setBarStatus(false);
        App.navigateTo(context, "/",transition: TransitionType.fadeIn,clearStack: true);
      }
    });
    super.initState();
    //开启动画
    _animationController.forward();

  }

  @override
  Widget build(BuildContext context) {
    return FadeTransition(
      opacity: _animation,
      //child: Image.network("https://pic2016.ytqmx.com/2019/0521/47/1.jpg!960.jpg",
      child: Image.asset(
        "assets/images/960.jpg",
        fit: BoxFit.cover,
      ),
    );
  }

}
